package com.xxc.exam.service.impl

import com.xxc.exam.entity.CategoryEntity
import com.xxc.exam.service.CategoryService
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
import java.math.BigInteger

@RunWith(SpringJUnit4ClassRunner::class)
@SpringBootTest
class CategoryServiceImplTest {

    @Autowired
    lateinit var categoryService:CategoryService

    @Test
    fun selectAllEntities(){
        println(categoryService.selectAllEntities(6.toBigInteger()))
    }

    @Test
    fun getFullPathName()
    {
        println(categoryService.getFullPathName(14.toBigInteger()))
    }

    /**
     * 获取该id的所有祖先元素，通过parent属性递归获得
     */
    fun getParents(){

    }



    @Test
    fun insertCategory() {
        val root = CategoryEntity(name = "人文")
        root.children = ArrayList()
        val animal = CategoryEntity(name = "动物")
        root.children!!.add(animal)
        animal.children = ArrayList()
        animal.children!!.add(CategoryEntity(name = "狗"))
        categoryService.insertCategory(root, 6.toBigInteger())
        println(root)
    }

    @Test
    fun insertIfNotExist() {
    }

}
